<%--
  Created by IntelliJ IDEA.
  User: z5727
  Date: 2022/9/23
  Time: 16:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<c:set value="${pageContext.request.contextPath}" var="path"></c:set>
<!doctype html>
<html lang="en" class="pxp-root">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <link rel="shortcut icon" href="/static/web/images/favicon.png" type="image/x-icon">
    <link rel="preconnect" href="https://fonts.googleapis.com/">
    <link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;500;600;700&display=swap" rel="stylesheet">
    <link href="/static/web/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="/static/web/css/font-awesome.min.css">
    <link rel="stylesheet" href="/static/web/css/owl.carousel.min.css">
    <link rel="stylesheet" href="/static/web/css/owl.theme.default.min.css">
    <link rel="stylesheet" href="/static/web/css/animate.css">
    <link rel="stylesheet" href="/static/web/css/style.css">

    <title>申请职位状态</title>
</head>
<body style="background-color: var(--pxpSecondaryColorLight);">
<jsp:include page="/web/personal/inc/personalCenterHead"></jsp:include>

    <div class="pxp-dashboard-content-details">
        <h1>您申请的工作</h1>
        <p class="pxp-text-light">您申请的工作详情列表。</p>

        <div class="mt-4 mt-lg-5">
            <div class="row justify-content-between align-content-center">
                <div class="col-auto order-2 order-sm-1">
<%--                    <div class="pxp-candidate-dashboard-jobs-bulk-actions mb-3">--%>
<%--                        <select class="form-select select_val">--%>
<%--                            <option value="1">批量操作</option>--%>
<%--                            <option value="2">删除</option>--%>
<%--                        </select>--%>
<%--                        <button class="btn ms-2 cao_zuo">应用</button>--%>
<%--                    </div>--%>
                        <div class="pxp-company-dashboard-jobs-bulk-actions mb-3">
                            <button class="btn ms-2 batchDele" style="font-weight: bold;" disabled>批量删除</button>
                        </div>
                </div>
                <div class="col-auto order-1 order-sm-2">
                    <div class="pxp-candidate-dashboard-jobs-search mb-3">
                        <div class="pxp-candidate-dashboard-jobs-search-results me-3 apply_psoition_count">0 份工作申请</div>
                        <div class="pxp-candidate-dashboard-jobs-search-search-form">
                            <div class="input-group">
                                <span class="input-group-text search_all" style="cursor: pointer;color: #0a53be"><span class="fa fa-search"></span></span>
                                <input type="text" class="form-control search_application_keyword" placeholder="Search jobs...">
                            </div>
                            <input type="hidden" class="hidden_search">
                        </div>
                    </div>
                </div>
            </div>
            <div class="table-responsive application_jobs">

            </div>
        </div>
    </div>

    <footer>
        <div class="pxp-footer-copyright pxp-text-light">© 2021 Jobster. All Right By <a href="http://www.bootstrapmb.com/">bootstrapmb</a>.</div>
    </footer>
</div>

<script src="/static/web/js/jquery-3.4.1.min.js"></script>
<script src="/static/web/js/bootstrap.bundle.min.js"></script>
<script src="/static/web/js/owl.carousel.min.js"></script>
<script src="/static/web/js/nav.js"></script>
<script src="/static/web/js/Chart.min.js"></script>
<script src="/static/web/js/main.js"></script>
<script type="text/javascript">

    $(function (){
        initData(1);
        //更改页码（张佳炜）
        $(".application_jobs").on("click",".page-link",function (){
            let pageNum = $(this).html();
            initData(pageNum);
        })
        //点击垃圾桶取消申请（张佳炜）
        $(".application_jobs").on("click",".delete_one",function (){
            if (confirm("您是否要删除此条消息？")){
            let applyPositionId = $(this).data("id");
            $.get("/web/personal/homepage/deleteOneByApplyPositionId",
                {applyPositionId:applyPositionId},
                function (mes){
                    initData(1);
                    alert("取消申请成功！");
                })
            }
        })
        //批量操作
        $(".application_jobs").on("click",".select_all",function (){
            let checked = $(this).prop("checked");
            if(checked==true)
            {
                $(".batchDele").prop("disabled",false);
            }
            else{
                $(".batchDele").prop("disabled",true);
            }
            $(".application_jobs").find(".select_one").each(function (){
                $(this).prop("checked",checked);
            })
        });
        //选中全部删除
        $(".btn").click(deleteAll);
        //关键字搜索
        $(".search_application_keyword").blur(searchApplyPosition);
        //批量删除是否能够使用
        $(".application_jobs").on("click",".select_one",enableBatchDele);
    })
    function searchApplyPosition()
    {
        initData(1);
    }
    function deleteAll()
    {
        if (confirm("您是否要删除这些数据吗？")){
            var applyPositionIds= new Array();
            $(".application_jobs").find(".select_one").each(function (){
                let flag = $(this).prop("checked");

                if(flag==true)
                {
                    let applyPositionId = $(this).data("id");
                    applyPositionId = parseInt(applyPositionId);
                    applyPositionIds.push(applyPositionId);
                }
            })
             applyPositionIds = applyPositionIds.join(",");
            $.get("/web/personal/homepage/deleteSelectByApplyPositionIds",
                {applyPositionIds:applyPositionIds},
                function (mes){
                    initData(1);
                    alert("取消申请成功！");
                }
            )
        }
    }
    function initData(pageNum)
    {
        let keywords = $(".search_application_keyword").val();
        $(".hidden_search").val(keywords);
        let keyword = $(".hidden_search").val();
        let data={pageNum:pageNum,keyword:keyword};
        $.get("/web/personal/homepage/personalApplicationsJobsData",
        data,
        function (data){
            $(".application_jobs").html(data);
            let count = $(".application_jobs").find(".col-auto").data("id");
            $(".apply_psoition_count").html(count+" 个职位");
        }
        )
    }
    function enableBatchDele(){
        if($(this).prop("checked")==true){
            $(".batchDele").prop("disabled",false);
        }
        else {
            $(".batchDele").prop("disabled",true);
        }
    }
</script>
</body>
</html>
